<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <link rel="icon" href="favicon.ico" />
    <title>Html - 实验室</title>
    <style>
      html,
      body {
        border: 0;
        padding: 0;
        margin: 0;
        height: 100%;
        overflow: hidden;
      }
    </style>
  </head>
  <body>
    <div>Html 实验室</div>
  </body>
  <script>
   //  1   局部没有a ，就找全局，所以a=123
   var a1 = 123
   function fun1(){
    console.log('fun1,1', a1)
   }
   fun1();
//    // 2
   var a2 = 123
   function fun2(){
    console.log('fun2,1', a2)
    var a2 = 123
   }
   fun2();
   console.log('fun2,2', a2)
  //  3
   var a3 = 123
   function fun3(){
    console.log('fun3,1', a3)
    a3 = 456;
   }
   fun3();
   console.log('fun3,2', a3)
//    // 4
//    var a = 123
//    function fun(a){
//     alert(a) //underfind
//     a = 456
//    }
//    fun();
//    alert(a) //123
//    // 5
//    var a = 123
//    function fun(a){
//     alert(a)  //123
//     var a = 456
//    }
//    fun(123);
//    alert(a) //123
  </script>
</html>
